#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL n,ans;
map<LL,bool>mp;
LL md(LL x,LL y)
{
	while(x>y)x-=y;
	return x;
}
LL mul(LL a,LL b,LL mod)
{
	LL ans=0;
	for(;b;b>>=1,a=md(a+a,mod))
		if(b&1)ans=md(ans+a,mod);
	return ans;
}
LL qpow(LL a,LL b,LL mod)
{
	LL ans=1;
	for(;b;b>>=1,a=mul(a,a,mod))
		if(b&1)ans=mul(ans,a,mod);
	return ans;
}
LL gcd(LL a,LL b)
{
	return b?gcd(b,a%b):a;
}
bool check(LL x)
{
	if(x==2||x==3)return true;
	if(x==1||x%2==0)return false;
	for(LL i=1;i<=20;++i)
	{
		LL a=rand()%(x-2)+2,k=x-1,r=0,t;
		while(k%2==0)
		{
			++r;
			k>>=1;
		}
		a=qpow(a,k,x);
		t=a;
		while(r--)
		{
			a=mul(a,a,x);
			while(a==1&&t!=1&&t!=x-1)return false;
			t=a;
		}
		if(a!=1)return false;
	}
	return true;
}
LL f(LL x,LL c)
{
	return (mul(x,x,n)+c)%n;
}
LL prho(LL n,LL c)
{
	LL x=rand()%n,y=f(x,c),p;
	for(LL i=1;;++i)
	{
		p=gcd(abs(x-y),n);
		if(p>1&&p<n)return p;
		x=f(x,c);y=f(f(y,c),c);
		if(x==y)return n;
	}
}
void find(LL x)
{
	if(x==1)return;
	if(check(x))
	{
		if(!mp[x])
		{
			mp[x]=true;
			ans=ans/x*(x-1);
		}
		return;
	}
	LL t=x;
	while(t==x)t=prho(x,rand()%(x-1)+1);
	find(t);
	find(x/t);
	return;
}
int main()
{
	scanf("%lld",&n);
	srand(n);
	ans=n;
	find(n);
	printf("%lld\n",ans);
	return 0;
}
